/**
 *  开始
 *  名片div操作
 * @type {number}
 */
var carpageNum = 1;
var carpageSize = 8;
var cartol;
var jspageNum = 1;
var jspageSize = 8;

$("#card-e").click(function () {
    $("#exh-card").css("display", "block");
    $("#exh-cont").css("display", "none");
    $("#list-e").attr("class", "btn-exh-list-car");
    $("#card-e").attr("class", "btn-exh-list-ex");
    $("#exhcards").css("display", "none");
    $("#catexh").css("display", "block");
    ardList();
    $.jqPaginator('#pagination', {
        totalPages: cartol,
        visiblePages: 10,
        currentPage: 1,
        wrapper: '<ul class="pagination" style="margin: 0 0"></ul>',
        first: '<li class="first"><a href="javascript:void(0);">首页</a></li>',
        prev: '<li class="prev"><a href="javascript:void(0);">上一页</a></li>',
        next: '<li class="next"><a href="javascript:void(0);">下一页</a></li>',
        last: '<li class="last"><a href="javascript:void(0);">最后一页</a></li>',
        page: '<li class="page"><a href="javascript:void(0);">{{page}}</a></li>',
        onPageChange: function (num) {
            if (num > 0) {
                carpageNum = num;
                ardList();
            }
        }
    });

    $("[name='shit']").click(function () {
        var id = this.getAttribute("title"); //展会id
        $("#catexh").css("display", "none");
        $("#exhcards").css("display", "block");

        var datajson = {
            ehId: id, //展会id
            pageNum: jspageNum,
            pageSize: jspageSize
        };
        idcardlist(datajson);
        $('#pagination').jqPaginator('option', {
            totalPages: cartol,
            onPageChange: function (num) {
                if (num > 0) {
                    jspageNum = num;
                    // console.log(datajson);                数据信息完全后测试
                    idcardlist(datajson);
                }
            }
        });
    });
});

//获取单个展会展商名片信息
function idcardlist(str) {
    $("#exhcards").empty();
    $.ajax({
        type: "POST",
        url: "http://www.enet720.net:8080/zwkj/merchantcard/findAll",
        contentType: 'application/json;charset=UTF-8',
        dataType: 'json',
        async: false,
        data: JSON.stringify(str),
        success: function (data) {
            var d = data.data;
            // 如果数据查询成功，但是数据为空的判断处理
            if (d.total > 0) {
                cartol = Math.ceil(d.total / 9);
                if (cartol < 1) {
                    cartol = 1;
                }
                var list = d.list;
                for (var i = 0; i < list.length; i++) {
                    $("#exhcards").append("  <div class=\"col-xs-12 col-sm-6 col-md-4 col-lg-3 \">\n" +
                        "                <div class=\"exhibition_list\">\n" +
                        "                    <div class=\"list-car-content lis-b\">\n" +
                        "                          <ul>\n" +
                        "                              <li><span>公司名称:</span>" + list[i].merchantCmName + "</li>\n" +
                        "                              <li><span>职务:</span>" + list[i].merchantDties + "</li>\n" +
                        "                              <li><span>联系人:</span>" + list[i].merchantName + "</li>\n" +
                        "                              <li><span>手机号:</span>" + list[i].merchantPhone + "</li>\n" +
                        "                              <li><span>传真:</span>" + list[i].merchantFax + "</li>\n" +
                        "                              <li><span>电话:</span>" + list[i].merchantTelephone + "</li>\n" +
                        "                          </ul>\n" +
                        "                    </div>\n" +
                        "                </div>\n" +
                        "            </div>")                        //---------------------------------------------------------------展商名片div-------------------------------------------------------明天代写-
                }
            } else {
                $("#exhcards").append("抱歉，暂无该展会名片数据！嘿嘿嘿........请从新查找！<a href='../HTML/exhibit-list.html'\">返回上一页</a>。。。");
                cartol = 1;
            }
        },
        error: function () {
            alert("出错了,抱歉！")
        }
    });

}

//获取所有展会信息名片
function ardList() {
    var catstr = {
        pageNum: carpageNum,
        pageSize: carpageSize
    };
    $("#catexh").empty();
    $.ajax({
        type: "POST",
        url: "http://www.enet720.net:8080/zwkj/exhibition/findAll",
        contentType: 'application/json;charset=UTF-8',
        dataType: 'json',
        async: false,
        data: JSON.stringify(catstr),
        success: function (data) {
            var d = data.data;
            // 如果数据查询成功，但是数据为空的判断处理
            if (d.total > 0) {        //如果total有数据
                cartol = Math.ceil(data.data.total / 8);
                //判断 如果不够一页9条数据，分页底部还是一页
                if (cartol === 0) {
                    cartol = 1;
                }
                var list = d.list;
                for (var i = 0; i < list.length; i++) {
                    $("#catexh").append("   <div class=\"col-xs-12 col-sm-6 col-md-4 col-lg-3 \" name='shit' title='" + list[i].exhibitionId + "'>\n" +
                        "                <div class=\"exhibition_list\">\n" +
                        "                    <div class=\"list-title\">\n" +
                        "                        <span>" + list[i].exhibitionName + "</span>\n" +
                        "                    </div>\n" +
                        "                    <div class=\"list-content\">\n" +
                        "                        <span class=\"list-content-title\">\n" +
                        "                        ---" + list[i].exhibitionAddress + "\n" +
                        "                        </span>\n" +
                        "                    </div>\n" +
                        "                    <div class=\"div-Radius\"></div>\n" +
                        "                    <span class=\"list-span\">名片</span>\n" +
                        "                </div>\n" +
                        "            </div>")
                }
            } else {                  //如果total没有数据出题的办法
                $("#catexh").append("抱歉暂无数据！")
            }

        },
        error: function () {
            alert("出错了,抱歉！")
        }
    });
}
/**
 *  结束
 *  名片div操作
 * @type {number}
 */
